package ru.osu.acm.system;

import java.util.Date;
import java.io.PrintWriter;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;

/**
 * User: Aleksey
 * Date: 25.02.2009
 * Time: 10:29:40
 */
public class Logger {
    private static PrintWriter log;

    static {
        try {
            log = new PrintWriter(new FileOutputStream("system.log", true));
        }
        catch (FileNotFoundException e) {
            e.printStackTrace();
        }
    }

    public static void log(String line) {
        line = new Date() + ": " + line;
        System.out.println(line);
        log.println(line);
        log.flush();
    }

    public static void logError(Exception e) {
        String line = new Date() + ":";
        System.out.println(line);
        log.println(line);
        e.printStackTrace();
        e.printStackTrace(log);
        log.flush();
    }
}
